XPMTranslator
version 1.1.0 (PPC version)
by Ernest Tomlinson

XPMTranslator is a translator add-on, written for Jon Watte's Datatypes library (as of version 1.6.3) for BeOS PR2 for PowerPC, which reads in XPM graphics files and converts them to Be's internal bitmap representation, and which also can write out XPM files from Be bitmap data.  This allows transparent use of XPM images by DTPicView or GraphicConverter, or any other application which uses Datatypes.  Drop it in the "Datatypes" directory on your system.

XPM files, MIME type "image/x-xpixmap", are designed for portable, if wasteful, and extensible representation of pixmaps of any desired color depth.  Transparency is supported, which this XPMTranslator recognizes.  Detailed information on the format is available at the XPM Home page at the following address:

http://www.inria.fr/koala/lehors/xpm.html

XPMTranslator is now extremely forgiving.  Colors in XPM files can be specified, among other ways, with the names of the X colors defined in the X11 rgb.txt file.  To cover this possibility, I hardcoded a list of X colors into XPMTranslator, basing the RGB values for them on an rgb.txt file taken from an old XFree86 installation (version 3.1.1, I think.)  Any colors not found in this list, or otherwise not defined, are given the RGB value #000000, or dead black.  Pixels undefined, thanks to corruption of the XPM file or for some other reason, are also filled in with black.

I've added some improvements to the XPM scanning code to improve the poor
efficiency of the last version of XPMTranslator, 1.0.0.  The time to translate of large XPM files containing many distinct colors is now down to fractions of a second, as opposed to the fractions of a minute needed for version 1.0.0, but is still quite a bit slower than the translation of other sorts of images (TIFF data, say.)  Writing an XPM file is less
efficient, however, and may take many seconds with images containing hundreds of distinct colors.

I've included with the translator a couple of XPM files for testing:  cross.xpm demonstrates the use of transparency, while sulla.xpm is a large XPM file, a picture of a bust of Roman statesman and dictator L. Cornelius Sulla Felix.  (Just to give an idea:  the run-length encoded TIFF file of Sulla Felix is less than one-half the size, and loads almost instantly with the TIFFTranslator included with BeOS R3.  XPMTranslator 1.1.0 reads
in the equivalent XPM file in maybe half a second.)

Version history

1.1.0 (10 May 1998):  added write capability; added hash-table code to XPM scanning
functions, to improve speed of translation.

Ernest Tomlinson
email:  etomlins@rohan.sdsu.edu
web "page":  http://www.ugcs.caltech.edu/~et/
